<?php
use yii\helpers\Html;
use front\assets\AppAsset;
use yii\helpers\Url;

$cssstring = 'ul.m-table-view .m-table-view-cell a {font-size: 1rem;display: block;}ul.m-table-view .m-table-view-cell a .icon {margin-right: 1rem;}body{background-color: rgba(235,240,242,1)}';
$this->registerCss($cssstring);
?>

<div class="m-pay-desc">
    商品名称：<?= $body?><br/>
    <h6>您需支付：<span>￥<?= $totalprice?></span></h6>
</div>

<ul class="m-table-view" style="margin-top: 10px">
    <li class="m-table-view-cell">
        <a href="javascript:void(0);" class="m-navigate-right" onclick="WXPayment()"><i class="icon icon-weixin" style="color: rgba(87,168,75,1);"></i>微信支付</a>
    </li>
</ul>



<script>
    var WXPayment = function() {
        if( typeof WeixinJSBridge === 'undefined' ) {
            msgPopup('请在微信在打开页面！');
            return false;
        }
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest',<?= $payment ?>,  function(res) {
                switch(res.err_msg) {
                    case 'get_brand_wcpay_request:cancel':
                        msgPopup('用户取消支付！');
                        break;
                    case 'get_brand_wcpay_request:fail':
                        msgPopup('支付失败！（'+res.err_desc+'）');
                        break;
                    case 'get_brand_wcpay_request:ok':
                        msgPopup('支付成功！');
//                        window.location.reload();
                        window.location.href = "/web/my";
                        break;
                    default:
                        msgPopup(JSON.stringify(res));
                        break;
                }
            });
    }
</script>